<?php
   
    /*忘记密码处理   根据用户名或邮箱，调用函数发送随机密码至邮箱，并更新用户数据表密码  
     * @param noe
     * @param email
     * @param newPass 随机生成新密码
     *  */
    header("Content-type:text/html;charset=utf-8");
    require_once '../inc/user.php';
    $message="";
    if (isset($_POST["noe"])) 
    {
        $curUser=getUserNameEmail($_POST["noe"]);
        $uId=$curUser["uId"];
        $to=$curUser["email"];
        @$uName=$curUser[uName];
        $newPass=getRandomStr();
        $result=email($to, $newPass);
        if ($result==true )
        {
            $update=updatePass($uId, $newPass);
            echo "<script language='JavaScript'>;alert('密码发送成功');window.location.href='../style/login.php';</script>";
           
            return;
        }
        else
        {
            $message="密码发送失败，请检查网络，也可能是邮箱崩了";
           
        }
   
    }
    else
    {
        $message="用户名或邮箱不能为空";
        
    }
    header("location:../style/errorNew.php?message=$message");
?>